home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Q: gets, getch, and stdin
- Date: 24 Mar 1996 12:50:19 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4j4cibINNgaf@keats.ugrad.cs.ubc.ca>
- References: <DnoC9w.Eq9@info.uucp> <31503557.2A97@willows.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <31503557.2A97@willows.com>,
- Tarang Deshpande <tarang@willows.com> wrote:
- >Chris Redekop u wrote:
- >>
- >>
- >> while ((ch = getch()) != '\r')
- >> ;
- >>
- >> while ((ch = getchar()) != '\n')
- >> ;
- >
- >The reason the \n works and \r does not is because \r means carriage
- >return whereas \n mean new line. \n means new line reguardless of
-
- Not to mention that getch() is not a standard C function whereas getchar() is.
-
- >what OS your using. Some OS use <CR><LF> combination for \n other
-
- That may be true for streams open in text mode.
-
- >use only <LF> and so on. So \r does not necessarily mean end of line,
- >where as \n does.
-
- You are completely false. The constant '\n' codes for exactly one character,
- not two. It cannot represent a CR/LF combination. It only means ``end of line''
- in the context of the standard input and output library.
-
- I think what you are trying to say is that the standard I/O functions will
- convert what is a CR/LF pair at the OS or hardware level to and from a '\n'
- character on output and input respectively.
-
- If you open a file in binary mode, no such translation should take place, hence
- '\n' doesn't intrinsically _mean_ ``end of line''.
-
- In fact, on ascii-based implementations, an untranslated '\n' typically
- corresponds to the ascii LF (character 10) and '\r' is character 13, CR.
-
-
- --
-
-